﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ShopOnline.DAL;

namespace ShopOnline.BLL
{
    public class BannerKey
    {
        public const string ProductPages = "Product Pages";
        public const string Cart = "Cart";
        public const string Wishlist = "Wishlist";
        public const string Register = "Register";
        public const string Contact = "Contact";
        public const string MyAccount = "My Account";
        public const string Default = "Default";
    }

    public class PageBanners : _PageBanners
    {
        public static PageBanners GetBanner(string page)
        {
            PageBanners banner = new PageBanners();
            banner.Where.Page.Value = page;
            banner.Where.Active.Value = true;
            banner.Query.Load();

            if (banner.RowCount == 0)
            {
                PageBanners banner1 = new PageBanners();
                banner1.Where.Page.Value = BannerKey.Default;
                banner1.Where.Active.Value = true;
                banner1.Query.Load();
                return banner1;
            }

            return banner;
        }

        public static PageBanners GetByID(int id)
        {
            PageBanners banner = new PageBanners();
            banner.LoadByPrimaryKey(id);

            if (banner.RowCount == 0)
            {
                banner.Where.Page.Operator = MyGeneration.dOOdads.WhereParameter.Operand.IsNull;
                banner.Query.Load();
            }

            return banner;
        }
    }
}
